package com.lims.landInfo.service;

import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javacommon.base.*;
import cn.org.rapid_framework.page.*;

import com.lims.landInfo.model.*;
import com.lims.landInfo.dao.*;
import com.lims.landInfo.vo.query.*;

/**
 * @author zzh
 * @version 1.0
 * @since 1.0
 */@Service
@Transactional @SuppressWarnings("unchecked")
public class LandDictionaryManager extends BaseManager<LandDictionary,java.lang.String>{

	private LandDictionaryDao landDictionaryDao;
	/**增加setXXXX()方法,spring就可以通过autowire自动设置对象属性,请注意大小写*/
	public void setLandDictionaryDao(LandDictionaryDao dao) {
		this.landDictionaryDao = dao;
	}
	
	public EntityDao getEntityDao() {
		return this.landDictionaryDao;
	}
	
	@Transactional(readOnly=true)
	public Page findPage(LandDictionaryQuery query) {
		return landDictionaryDao.findPage(query);
	}
	
	@Transactional(readOnly=true)
	public ListRange findRange(LandDictionaryQuery query) {
		Page page = this.landDictionaryDao.findPage(query);
		ListRange listRange = new ListRange();
		listRange.setRows(page.getResult().toArray());
		listRange.setTotal(page.getTotalCount());
		return listRange;
	}
	/**
	 * 组装数据字典放入Map中
	 * Map {colno:[{}{}]}
	 * @return
	 */
	@Transactional(readOnly=true)
	public Map findAllToMap() {
		Map map = new HashMap();
		String hql = "select ld.colno from LandDictionary ld group by ld.colno";
		List list = this.landDictionaryDao.findByHQL(hql);
		String cHql = "from LandDictionary ld where ld.colno=";
		for (Iterator iterator = list.iterator(); iterator.hasNext();) {
			String colno = (String) iterator.next();
			List cList = this.landDictionaryDao.findByHQL(cHql+"'"+colno+"'");
			map.put(colno, cList);
		}
		return map;
	}
	
}
